package com.edu.exam.enums.grading;

/**
 * 审计操作结果枚举
 */
public enum AuditOperationResult {
    SUCCESS("SUCCESS", "成功"),
    FAILURE("FAILURE", "失败"),
    ERROR("ERROR", "错误"),
    PARTIAL("PARTIAL", "部分成功"),
    TIMEOUT("TIMEOUT", "超时"),
    CANCELLED("CANCELLED", "已取消"),
    SKIPPED("SKIPPED", "已跳过"),
    PENDING("PENDING", "待处理"),
    IN_PROGRESS("IN_PROGRESS", "进行中"),
    COMPLETED("COMPLETED", "已完成"),
    APPROVED("APPROVED", "已批准"),
    REJECTED("REJECTED", "已拒绝"),
    VALIDATED("VALIDATED", "已验证"),
    INVALID("INVALID", "无效");

    private final String code;
    private final String description;

    AuditOperationResult(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static AuditOperationResult fromCode(String code) {
        for (AuditOperationResult result : values()) {
            if (result.getCode().equals(code)) {
                return result;
            }
        }
        return PENDING; // 默认返回待处理
    }
}